/* 
 * File:   v4l.h
 * Author: gustavo
 *
 * Created on January 1, 2012, 6:07 AM
 */

#ifndef V4L_H
#define	V4L_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <linux/videodev2.h>
#include <libv4lconvert.h>
#include <util/list.h>

#define DEVICE_NAME_MAX_LENGTH 32

	struct buffer {
		void * start;
		size_t length;
	};

	struct v4l_buffers {
		int qtd;
		struct buffer * buffers;
	};

	struct v4l_driver {
		int fd;
		int fmt_emulation;
		struct v4l_buffers v4lbuffers;
		int eq_i;
		int dq_i;

		int width;
		int height;

		struct v4lconvert_data * v4lconv;
		struct v4l2_format format_src;
		int bytesused;
		
		struct v4l2_control ctrl;

		void * buf_pointer;
		void * buffer_raw;
	};

	List * v4l_get_device_list(void);

	//struct v4l_driver v4l_open(char * device, int fmt_emulation);
	struct v4l_driver v4l_open_default(char * device);
	int v4l_close(struct v4l_driver * v4ldrv);

	int v4l_start(struct v4l_driver * v4ldrv);
	int v4l_stop(struct v4l_driver * v4ldrv);

	void * v4l_grab_raw(struct v4l_driver * v4ldrv);
	void * v4l_grab_gray(struct v4l_driver * v4ldrv, char * gray);
	void * v4l_grab_rgb(struct v4l_driver * v4ldrv, char * rgb);









#ifdef	__cplusplus
}
#endif

#endif	/* V4L_H */

